<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const cai = {
        uname: '只因',
        age: 2.5,
        hobbit: ['sing', 'dance', 'rap', 'basketball'],
        fans: {
          uname: 'ikun',
          age: 9999,
          hobbit: ['smoke', 'drink', 'makeHairStyle'],
        },
      }  
      const xin={}
      function fn(newXin,newCai){
        for(let k in newCai){
            if(newCai[k] instanceof Array){
                newXin[k]=[]
                fn(newXin[k],newCai[k])
            }else if(newCai[k] instanceof Object){
                newXin[k]={}
                fn(newXin[k],newCai[k])
            } else{
                newXin[k]=newCai[k]
            } 
        }
      }
      fn(xin,cai)
      console.log(xin);
    </script>
</body>
</html>